


#pragma once

#include "../NSL(nexus standard library)/Lua/LuaUtility/NLuaState.h"
#include "../NSL(nexus standard library)/NIPAddr.h"

class CSampleServerConfig
{	

	public:
		bool isOK( void ) const { return m_bOK; };
		bool Init( void );
		bool RegisterServer( const std::string in_szServerName, const std::string in_szIP, const unsigned int in_nPort );		
		bool SetServerMinimumSessionObjectCnt( const std::string in_szServerName, const unsigned int in_MinimumSessionObjectCnt );

		NIPAddr      GetSvrIPaddr( const string in_Name );
		int          GetSvrPortNum( const string in_Name );
		unsigned int GetSvrMinimumSessionObjectCnt( const string in_Name );


	public:
		static bool CreateInstance( void );
		static void DestroyInstance( void );
		friend __forceinline CSampleServerConfig* InstanceCSampleServerConfig( void );

	private:
		bool LoadTbl( void );

	private:
		explicit CSampleServerConfig( void );
		CSampleServerConfig( CSampleServerConfig & );
		~CSampleServerConfig( void );
		CSampleServerConfig& operator=( CSampleServerConfig & );

	private:
		bool	m_bOK;
		static CSampleServerConfig* m_cpSelf;

		class lcSvr
		{
			public:
				explicit lcSvr( const string in_IPaddr, const unsigned int in_Port ) :  m_IPaddr( in_IPaddr) , m_Port( in_Port ), m_MinimumSessionObjectCnt(0){};
			public:
				string	     m_IPaddr;
				unsigned int m_Port;
				unsigned int m_MinimumSessionObjectCnt;
		};

		typedef stdext::hash_map< string, lcSvr > SERVERINFOMAP;
		SERVERINFOMAP	m_SvrInfoMap;
};

__forceinline CSampleServerConfig* InstanceCSampleServerConfig( void ) { return CSampleServerConfig::m_cpSelf; };